package com.order.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 张占恒.
 * @date 2020/7/19.
 * @time 10:17.
 */
public class ResourceConfig implements WebMvcConfigurer {
    @Autowired
    private PayConfig payConfig;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        String os =System.getProperty("os.name");
        if(os.toLowerCase().startsWith("win")) { //判断是否win系统
            registry.addResourceHandler(payConfig.getHttpResourcePath()+"/**")
                    .addResourceLocations("file:"+payConfig.getQrBasePath()+"/");
        }else {
            registry.addResourceHandler("/static/resources/**")
                    .addResourceLocations("file:/usr/local/resources/"); //静态资源
        }
    }
}
